package com.hopu.oa.dao.user;

import com.hopu.oa.entity.user.AoaNotepaper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserPlaneDao {
    /**
     * 获取便签
     */
    @Select("<script> select * from aoa_notepaper where notepaper_user_id = #{id} order by create_time desc <if test='size !=0'> limit #{index},#{size} </if></script>")
    List<AoaNotepaper> queryNotepaper(@Param("id") int id, @Param("index") int index, @Param("size") int size);

    /**
     * 根据id查询消息
     *
     * @param id
     * @return
     */
    @Select("select count(*) from aoa_notice_list where user_id=#{id}")
    int selectNoticeByUserId(int id);

    /**
     * 根据id查询邮件
     *
     * @param id
     * @return
     */
    @Select("select count(*) from aoa_in_mail_list where mail_in_push_user_id=#{id} ")
    int selectEmailByUserId(int id);

    /**
     * 添加便签
     *
     * @param notepaper
     * @return
     */
    @Insert("insert into aoa_notepaper(title,concent,create_time,notepaper_user_id) values(#{title},#{concent},#{createTime},#{notepaperUserId})")
    int addNotepaperById(AoaNotepaper notepaper);

    /**
     * 修改便签
     */
    @Update("update aoa_notepaper set title=#{title},concent=#{concent} where notepaper_id =#{notepaperId}")
    int updateNotepaper(AoaNotepaper notepaper);

    /**
     * 删除便签
     */
    @Delete("delete from aoa_notepaper where notepaper_id =#{notepaperId}")
    int deleteNotepaper(int notepaperId);
}
